﻿using BCDto.TMS.Packing.PackingConfig;
using BCService.TMS.Packing.PackingConfig;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace BCTMSRESTful.Controllers.ClientApp.Packing.PackingConfig
{
    /// <summary>
    /// 包装材料配置
    /// </summary>
    [Route("api/v1/ClientApp/[controller]")]
    [ApiExplorerSettings(GroupName = "ClientApp")]
    [AllowAnonymous]
    public class PackingConfigController : ClientAppBaseController
    {
        private readonly IPackingConfigService packingConfigService;

        public PackingConfigController(IPackingConfigService packingConfigService)
        {
            this.packingConfigService = packingConfigService;
        }

        /// <summary>
        /// 获取包装材料配置记录列表
        /// </summary>
        /// <param name="packingCategoryConfigId">包装材料分类配置Id</param>
        /// <param name="provinceCode">省份编码</param>
        /// <param name="cityCode">市编码</param>
        /// <param name="countyCode">区县编码</param>
        /// <response code="200">获取包装材料配置记录列表</response>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(IEnumerable<PackingConfigViewDto>), 200)]
        public IActionResult List([FromQuery(Name = "packing_category_config_id")] int? packingCategoryConfigId,
            [FromQuery(Name = "province_code")] string provinceCode,
            [FromQuery(Name = "city_code")] string cityCode,
            [FromQuery(Name = "county_code")] string countyCode)
        {
            long? agentRecordId = this.GetAgentRecordIdByCountyCode(countyCode);
            var result = this.packingConfigService.GetList(agentRecordId, packingCategoryConfigId, provinceCode, cityCode, countyCode);
            return this.Ok(result);
        }
    }
}
